// Created from GenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Reflection;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.Generated.AbstractMessage;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using TX = System.String;
using FT = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class VXU_V04 : AbstractMessage
    {
		/// Constructor
		public VXU_V04() : base()
        {
			if (MSH != null) {
                MSH.MessageType = new MSG() { MessageCode = "VXU", TriggerEvent = "V04" };
			}
        }

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PID",2)]
  	    [HL7Field(HL7Version.v23, 2, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v231, 2, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v24, 2, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v25, 3, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v251, 3, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v26, 4, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v27, 4, HL7Repeat.False, HL7Required.True,"PID")]
	    public PID PID {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PD1",4)]
  	    [HL7Field(HL7Version.v23, 4, HL7Repeat.False, HL7Required.False,"PD1")]
  	    [HL7Field(HL7Version.v231, 4, HL7Repeat.False, HL7Required.False,"PD1")]
  	    [HL7Field(HL7Version.v24, 4, HL7Repeat.False, HL7Required.False,"PD1")]
  	    [HL7Field(HL7Version.v25, 4, HL7Repeat.False, HL7Required.False,"PD1")]
  	    [HL7Field(HL7Version.v251, 4, HL7Repeat.False, HL7Required.False,"PD1")]
  	    [HL7Field(HL7Version.v26, 5, HL7Repeat.False, HL7Required.False,"PD1")]
  	    [HL7Field(HL7Version.v27, 5, HL7Repeat.False, HL7Required.False,"PD1")]
	    public PD1 PD1 {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("NK1",8)]
  	    [HL7Field(HL7Version.v23, 8, HL7Repeat.True, HL7Required.False,"NK1")]
  	    [HL7Field(HL7Version.v231, 8, HL7Repeat.True, HL7Required.False,"NK1")]
  	    [HL7Field(HL7Version.v24, 8, HL7Repeat.True, HL7Required.False,"NK1")]
  	    [HL7Field(HL7Version.v25, 5, HL7Repeat.True, HL7Required.False,"NK1")]
  	    [HL7Field(HL7Version.v251, 5, HL7Repeat.True, HL7Required.False,"NK1")]
  	    [HL7Field(HL7Version.v26, 6, HL7Repeat.True, HL7Required.False,"NK1")]
  	    [HL7Field(HL7Version.v27, 6, HL7Repeat.True, HL7Required.False,"NK1")]
	    public NK1[] NK1 {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PATIENT",11)]
  	    [HL7Field(HL7Version.v23, 11, HL7Repeat.False, HL7Required.False,"PATIENT_VXU_V04")]
  	    [HL7Field(HL7Version.v231, 11, HL7Repeat.False, HL7Required.False,"PATIENT_VXU_V04")]
  	    [HL7Field(HL7Version.v24, 11, HL7Repeat.False, HL7Required.False,"PATIENT_VXU_V04")]
  	    [HL7Field(HL7Version.v25, 6, HL7Repeat.False, HL7Required.False,"PATIENT_VXU_V04")]
  	    [HL7Field(HL7Version.v251, 6, HL7Repeat.False, HL7Required.False,"PATIENT_VXU_V04")]
  	    [HL7Field(HL7Version.v26, 7, HL7Repeat.False, HL7Required.False,"PATIENT_VXU_V04")]
  	    [HL7Field(HL7Version.v27, 7, HL7Repeat.False, HL7Required.False,"PATIENT_VXU_V04")]
	    public PATIENT_VXU_V04 PATIENT {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("INSURANCE",17)]
  	    [HL7Field(HL7Version.v23, 17, HL7Repeat.False, HL7Required.False,"INSURANCE_VXU_V04")]
  	    [HL7Field(HL7Version.v231, 17, HL7Repeat.False, HL7Required.False,"INSURANCE_VXU_V04")]
  	    [HL7Field(HL7Version.v24, 22, HL7Repeat.False, HL7Required.False,"INSURANCE_VXU_V04")]
  	    [HL7Field(HL7Version.v25, 11, HL7Repeat.True, HL7Required.False,"INSURANCE_VXU_V04")]
  	    [HL7Field(HL7Version.v251, 11, HL7Repeat.True, HL7Required.False,"INSURANCE_VXU_V04")]
  	    [HL7Field(HL7Version.v26, 12, HL7Repeat.True, HL7Required.False,"INSURANCE_VXU_V04")]
  	    [HL7Field(HL7Version.v27, 12, HL7Repeat.True, HL7Required.False,"INSURANCE_VXU_V04")]
	    public INSURANCE_VXU_V04[] INSURANCE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("ORDER",28)]
  	    [HL7Field(HL7Version.v23, 28, HL7Repeat.False, HL7Required.False,"ORDER_VXU_V04")]
  	    [HL7Field(HL7Version.v231, 28, HL7Repeat.False, HL7Required.False,"ORDER_VXU_V04")]
  	    [HL7Field(HL7Version.v24, 33, HL7Repeat.False, HL7Required.False,"ORDER_VXU_V04")]
  	    [HL7Field(HL7Version.v25, 16, HL7Repeat.True, HL7Required.False,"ORDER_VXU_V04")]
  	    [HL7Field(HL7Version.v251, 16, HL7Repeat.True, HL7Required.False,"ORDER_VXU_V04")]
  	    [HL7Field(HL7Version.v26, 17, HL7Repeat.True, HL7Required.False,"ORDER_VXU_V04")]
  	    [HL7Field(HL7Version.v27, 17, HL7Repeat.True, HL7Required.False,"ORDER_VXU_V04")]
	    public ORDER_VXU_V04[] ORDER {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("GT1",19)]
  	    [HL7Field(HL7Version.v24, 19, HL7Repeat.True, HL7Required.False,"GT1")]
  	    [HL7Field(HL7Version.v25, 10, HL7Repeat.True, HL7Required.False,"GT1")]
  	    [HL7Field(HL7Version.v251, 10, HL7Repeat.True, HL7Required.False,"GT1")]
  	    [HL7Field(HL7Version.v26, 11, HL7Repeat.True, HL7Required.False,"GT1")]
  	    [HL7Field(HL7Version.v27, 11, HL7Repeat.True, HL7Required.False,"GT1")]
	    public GT1[] GT1 {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("SFT",2)]
  	    [HL7Field(HL7Version.v25, 2, HL7Repeat.True, HL7Required.False,"SFT")]
  	    [HL7Field(HL7Version.v251, 2, HL7Repeat.True, HL7Required.False,"SFT")]
  	    [HL7Field(HL7Version.v26, 2, HL7Repeat.True, HL7Required.False,"SFT")]
  	    [HL7Field(HL7Version.v27, 2, HL7Repeat.True, HL7Required.False,"SFT")]
	    public SFT[] SFT {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("UAC",3)]
  	    [HL7Field(HL7Version.v26, 3, HL7Repeat.False, HL7Required.False,"UAC")]
  	    [HL7Field(HL7Version.v27, 3, HL7Repeat.False, HL7Required.False,"UAC")]
	    public UAC UAC {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override Stack<string> ConsumeTextSegments(Stack<string> availableData, HL7ParserOptions options) {

				if (HL7Version.v23 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PD1 = PopSegmentParseAndCheckRequired<PD1>(availableData, options, "PD1");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 PATIENT = ProcessGroup<PATIENT_VXU_V04>(availableData, options, "PATIENT");
		 INSURANCE = ProcessGroupArray<INSURANCE_VXU_V04>(availableData, options, "INSURANCE");
		 ORDER = ProcessGroupArray<ORDER_VXU_V04>(availableData, options, "ORDER");
		}
		if (HL7Version.v231 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PD1 = PopSegmentParseAndCheckRequired<PD1>(availableData, options, "PD1");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 PATIENT = ProcessGroup<PATIENT_VXU_V04>(availableData, options, "PATIENT");
		 INSURANCE = ProcessGroupArray<INSURANCE_VXU_V04>(availableData, options, "INSURANCE");
		 ORDER = ProcessGroupArray<ORDER_VXU_V04>(availableData, options, "ORDER");
		}
		if (HL7Version.v24 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PD1 = PopSegmentParseAndCheckRequired<PD1>(availableData, options, "PD1");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 PATIENT = ProcessGroup<PATIENT_VXU_V04>(availableData, options, "PATIENT");
		 INSURANCE = ProcessGroupArray<INSURANCE_VXU_V04>(availableData, options, "INSURANCE");
		 ORDER = ProcessGroupArray<ORDER_VXU_V04>(availableData, options, "ORDER");
		 GT1 = PopSegmentParseAndCheckRequiredArray<GT1>(availableData, options, "GT1");
		}
		if (HL7Version.v25 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PD1 = PopSegmentParseAndCheckRequired<PD1>(availableData, options, "PD1");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 PATIENT = ProcessGroup<PATIENT_VXU_V04>(availableData, options, "PATIENT");
		 INSURANCE = ProcessGroupArray<INSURANCE_VXU_V04>(availableData, options, "INSURANCE");
		 ORDER = ProcessGroupArray<ORDER_VXU_V04>(availableData, options, "ORDER");
		 GT1 = PopSegmentParseAndCheckRequiredArray<GT1>(availableData, options, "GT1");
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		}
		if (HL7Version.v251 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PD1 = PopSegmentParseAndCheckRequired<PD1>(availableData, options, "PD1");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 PATIENT = ProcessGroup<PATIENT_VXU_V04>(availableData, options, "PATIENT");
		 INSURANCE = ProcessGroupArray<INSURANCE_VXU_V04>(availableData, options, "INSURANCE");
		 ORDER = ProcessGroupArray<ORDER_VXU_V04>(availableData, options, "ORDER");
		 GT1 = PopSegmentParseAndCheckRequiredArray<GT1>(availableData, options, "GT1");
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		}
		if (HL7Version.v26 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PD1 = PopSegmentParseAndCheckRequired<PD1>(availableData, options, "PD1");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 PATIENT = ProcessGroup<PATIENT_VXU_V04>(availableData, options, "PATIENT");
		 INSURANCE = ProcessGroupArray<INSURANCE_VXU_V04>(availableData, options, "INSURANCE");
		 ORDER = ProcessGroupArray<ORDER_VXU_V04>(availableData, options, "ORDER");
		 GT1 = PopSegmentParseAndCheckRequiredArray<GT1>(availableData, options, "GT1");
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		 UAC = PopSegmentParseAndCheckRequired<UAC>(availableData, options, "UAC");
		}
		if (HL7Version.v27 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PD1 = PopSegmentParseAndCheckRequired<PD1>(availableData, options, "PD1");
		 NK1 = PopSegmentParseAndCheckRequiredArray<NK1>(availableData, options, "NK1");
		 PATIENT = ProcessGroup<PATIENT_VXU_V04>(availableData, options, "PATIENT");
		 INSURANCE = ProcessGroupArray<INSURANCE_VXU_V04>(availableData, options, "INSURANCE");
		 ORDER = ProcessGroupArray<ORDER_VXU_V04>(availableData, options, "ORDER");
		 GT1 = PopSegmentParseAndCheckRequiredArray<GT1>(availableData, options, "GT1");
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		 UAC = PopSegmentParseAndCheckRequired<UAC>(availableData, options, "UAC");
		}
			if (availableData != null && availableData.Count > 0) {
				ConsumeZSegmentsFromText(availableData, options);
			}
            return availableData;
        
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "VXU_V04";
			}
        }

        static VXU_V04() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(VXU_V04));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
			if (MSH != null) {
				segmentData.Add(MSH.GetER7(options));
			}
			if (PID != null) {
				segmentData.Add(PID.GetER7(options));
			}
			if (PD1 != null) {
				segmentData.Add(PD1.GetER7(options));
			}
			if (NK1 != null && NK1.Length > 0) {
				for (int i = 0; i < NK1.Length; i++) {
					segmentData.Add(NK1[i].GetER7(options));
				}
			}
			if (PATIENT != null) {
				segmentData.Add(PATIENT.GetER7(options));
			}
			if (INSURANCE != null && INSURANCE.Length > 0) {
				for (int i = 0; i < INSURANCE.Length; i++) {
					segmentData.Add(INSURANCE[i].GetER7(options));
				}
			}
			if (ORDER != null && ORDER.Length > 0) {
				for (int i = 0; i < ORDER.Length; i++) {
					segmentData.Add(ORDER[i].GetER7(options));
				}
			}
			if (GT1 != null && GT1.Length > 0) {
				for (int i = 0; i < GT1.Length; i++) {
					segmentData.Add(GT1[i].GetER7(options));
				}
			}
			if (SFT != null && SFT.Length > 0) {
				for (int i = 0; i < SFT.Length; i++) {
					segmentData.Add(SFT[i].GetER7(options));
				}
			}
			if (UAC != null) {
				segmentData.Add(UAC.GetER7(options));
			}
           segmentData.AddRange(GetZSegmentsER7(options));
		   return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }


    }
}

